﻿using System;

namespace Entities
{
    [Serializable]
    public class Distance
    {
        private int stationA;
        private int stationB;
        private int distance;
        public Distance()
        { }
        public Distance(int stationA, int stationB, int distance)
        {
            this.stationA = stationA;
            this.stationB = stationB;
            this.distance = distance;
        }
        public int StationA
        {
            get { return this.stationA; }
            set
            {
                if (value < 0)
                    throw new Exception("stationA not allow nullvalue.");
                this.stationA = value;
            }
        }
        public int StationB
        {
            get { return this.stationB; }
            set
            {
                if (value < 0)
                    throw new Exception("stationB not allow nullvalue.");
                this.stationB = value;
            }
        }
        public int Distances
        {
            get { return this.distance; }
            set { this.distance = value; }
        }
        public override string ToString()
        {
            return this.stationA + "; " + this.stationB + "; " + this.distance + "; ";
        }
        public override bool Equals(Object obj)
        {
            Distance me = (Distance)obj;
            bool ret = this.StationA.Equals(me.StationA) && this.StationB.Equals(me.StationB);
            return ret;
        }
        public override int GetHashCode()
        {
            return this.StationA.GetHashCode() + this.StationB.GetHashCode();
        }

    }
}